package com.howcan.widget;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.widget.ImageView;

public class HoneyRequestNum extends ImageView
{
  int num = 0;
  Paint paint;

  public HoneyRequestNum(Context paramContext)
  {
    this(paramContext, null);
  }

  public HoneyRequestNum(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }

  public HoneyRequestNum(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    setImageResource(2130837643);
    this.paint = new Paint();
    this.paint.setColor(-1);
    this.paint.setTypeface(Typeface.SANS_SERIF);
    this.paint.setAntiAlias(true);
  }

  public int num()
  {
    return this.num;
  }

  protected void onDraw(Canvas paramCanvas)
  {
    if (this.num <= 0) return;
    super.onDraw(paramCanvas);
    float f1 = getResources().getDisplayMetrics().density;
    String str;
    if ((this.num < 100) || (this.num >= 10000))
        str = "~";
    else
    	str = String.valueOf(this.num);

      float f2 = f1 * 10;
      this.paint.setTextSize(f2);
      float f3 = this.paint.measureText(str);
      float f4 = -this.paint.ascent() + this.paint.descent();
      this.paint.setTypeface(Typeface.defaultFromStyle(1));
      paramCanvas.drawText(str, (getWidth() - f3) / 2.0F, (getHeight() - f4) / 2.0F - this.paint.ascent() - 2.5F * f1, this.paint);
      return;
  }

  public void setNum(int paramInt)
  {
    this.num = paramInt;
    invalidate();
  }
}
